<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/player.main.css">
	</head>

	<body>
		<div class='jAudio--player' style="margin-top: 0;">

			<audio></audio>

			<div class='jAudio--ui'>

				<div class='jAudio--thumb'></div>

				<div class='jAudio--status-bar' style="padding: 40px 20px 0 20px;">

					<div class='jAudio--details'></div>
					<div class='jAudio--volume-bar'></div>
					<div class='jAudio--time' style="margin-top: 72px;">
						<span class='jAudio--time-elapsed'>00:00</span>
						<span class='jAudio--time-total'>00:00</span>
					</div>
					<div class='jAudio--progress-bar' style="margin: 8px 0 0 0;">
						<div class='jAudio--progress-bar-wrapper'>
							<div class='jAudio--progress-bar-played'>
								<span class='jAudio--progress-bar-pointer'></span>
							</div>
						</div>
					</div>

				</div>

			</div>

			<div class='jAudio--controls'>
				<ul>
					<li><button class='btn' data-action='prev' id='btn-prev'><span></span></button></li>
					<li><button class='btn' data-action='play' id='btn-play'><span></span></button></li>
					<li><button class='btn' data-action='next' id='btn-next'><span></span></button></li>
				</ul>
			</div>

			<div class='jAudio--playlist'>
			</div>

		</div>

		<script src='js/jquery-2.1.4.min.js'></script>
		<script src="js/mui.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/common.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/jaudio.js" type="text/javascript" charset="utf-8"></script>
		<script>
			//			var t = {
			//				playlist: [{
			//					file: "http://182.92.165.168/849727481473706861128.mp3",
			//					thumb: "img/detail_img.png",
			//					trackName: "鸟之诗",
			//					trackArtist: "巡音ルカ",
			//					trackAlbum: "巡音ルカ",
			//				}, {
			//					file: "http://182.92.165.168/849727481473706861128.mp3",
			//					thumb: "img/detail_img.png",
			//					trackName: "鸟之诗",
			//					trackArtist: "巡音ルカ",
			//					trackAlbum: "巡音ルカ",
			//				}],
			//				autoPlay: false
			//			};
			//			$(".jAudio--player").jAudio(t);

			$(function() {
				var row = JSON.parse(window.sessionStorage.getItem("$row"));
				if($.getUrlParam('tag') == '试听') {
					row = JSON.parse(window.sessionStorage.getItem("$audition"));
				}
				if(typeof(row['fileUrl']) == 'undefined') {
					//播放专辑
					$.ajax({
						url: 'data/front_index/audios.json',
						data: {
							specialId: row['specialId']
						},
						success: function(r) {
							r = eval('(' + r + ')');
							alert(JSON.stringify(r));
							var playlist = [];
							for(var i in r.data) {
								playlist.push({
									file: r.data[i]['fileUrl'],
									thumb: $.getContextPath() + window.config.picPathBaseUrl + r.data[i]['imgUrl'],
									trackName: r.data[i]['frequencyName'],
									trackArtist: r.data[i]['author'],
									trackAlbum: r.data[i]['author'],
								});
								updatePlay(r.data[i]['frequencyId']);
							};
							var t = {
								playlist: playlist,
								autoPlay: true
							};
							$(".jAudio--player").jAudio(t);
						},
						error: function(xhr, errorType, error) {
							alert('^^^^^error:loadData:' + JSON.stringify(errorType) + " " + JSON.stringify(error));
							console.log('^^^^^error:loadData:' + JSON.stringify(errorType) + " " + JSON.stringify(error));
						}
					});
				} else {
					//播放单曲
					var t = {
						playlist: [{
							file: row['fileUrl'],
							thumb: $.getContextPath() + window.config.picPathBaseUrl + row['imgUrl'],
							trackName: row['frequencyName'],
							trackArtist: row['author'],
							trackAlbum: row['author'],
						}],
						autoPlay: true
					};
					updatePlay(row['frequencyId']);
					$(".jAudio--player").jAudio(t);
				}
			});

			/**
			 * 更新播放次数
			 * @param {Object} frequencyId
			 */
			function updatePlay(frequencyId) {
				$.ajax({
					type: "get",
					url: $.getContextPath() + "/weixin/front_subscribed/updatePlay",
					async: true,
					data: {
						frequencyId: frequencyId
					},
					success: function(r) {

					}
				});
			};
		</script>

	</body>

</html>